import 'package:flutter/material.dart';
import 'package:read_book/ui/pages/book_city/book_city.dart';
import 'package:read_book/ui/pages/book_shelf.dart';
import 'package:read_book/ui/pages/my_home.dart';

class BottomNavigationWidget extends StatefulWidget {
  const BottomNavigationWidget({Key key}) : super(key: key);

  @override
  BottomNavigationWidgetState createState() => BottomNavigationWidgetState();
}

class BottomNavigationWidgetState extends State<BottomNavigationWidget> {
  int _currentIndex = 1;
  List<Widget> list = [];

  @override
  void initState() {
    list = [BookShelf(), BookCity(), MyHome()];
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: list[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: const [
          BottomNavigationBarItem(
              icon: Icon(
                Icons.library_books,
                color: Colors.black54,
              ),
              label: '书架'),
          BottomNavigationBarItem(
              icon: Icon(
                Icons.home,
                color: Colors.black54,
              ),
              label: '书城'),
          BottomNavigationBarItem(
              icon: Icon(
                Icons.perm_identity,
                color: Colors.black54,
              ),
              label: '我的'),
        ],
        type: BottomNavigationBarType.fixed,
        currentIndex: _currentIndex,
        onTap: (int index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
    );
  }
}
